﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSGS07 
    {
       
        public TSGS07()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGSCOLOR();
            DataContext = MV;
            InitializeComponent();
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);            
        }
         
       
        public override void OnEXAUFChg(string vlaue)
        {
            if (EXAUF.Length < 23)
            {
                TBMain.Clear();
                return;
            }
            dwData = TBMain.NewRow();
            dwData["GSCMANDANT"] = app.Mandant;
            dwData["GSCART"] = EXAUF.Substring(1, 20);
            dwData["GSCVAR"] = EXAUF.Substring(21, 3);
            SResult = TMV.QGC_1(dwData);
            foreach (DataRow row in SResult.Tables[0].Rows)
            { 
                row["KEY"] = Helpers.Helper.GetGB2312Value(row["KEY"].ToString().Trim());
                row["DES"] = Helpers.Helper.GetGB2312Value(row["GSCBEZ"].ToString());
            }
            MergeData(SResult, false);
            if(TBMain.Rows.Count<2)
            {
                vwMaster.View.MoveCurrentToFirst();
            }
            base.OnEXAUFChg(vlaue);
        }


        public override void LOADBYAUF()
        {
            return;
            if (ORDERNUM.Length < 33)
                return;
            Locate("GSCFARBE", ORDERNUM.Substring(24, 10));
            base.LOADBYAUF();
        }

        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if(IsManage)
            {
                OnEXAUFChg(EXAUF);
            }
            else
            {
                VICC_WFEVENTS.SVWF.GS06(RUNID);
            }
            
            base.ManageCommand(sender, e);
        }

    }
}
